﻿/*
(c) 2010 - Open Source Business Foundation e. V. (www.osbf.de)
This software is provided under Microsoft Reciprocal License (Ms-RL)
(http://www.microsoft.com/opensource/licenses.mspx#Ms-RL)
All other rights reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

namespace MicroFormatProcessing
{

    /// <summary>
    /// This class is doing the database stuff for Microformats 
    /// Insert, Update, Delete
    /// </summary>
    class MicroFormatContext : TableServiceContext
    {
        public const string TABLE_NAME = "MicroFormats";

        public MicroFormatContext(string baseAdress, StorageCredentials storageCredentials) : base(baseAdress, storageCredentials)
        {
        }

        public IQueryable<MicroFormat> MicroFormats
        {
            get
            {
                return this.CreateQuery<MicroFormat>(TABLE_NAME);
            }
        }

        public void Add(MicroFormat microFormat)
        {
            this.AddObject(TABLE_NAME, microFormat);
        }

        public void Update(MicroFormat microFormat)
        {
            this.UpdateObject(microFormat);
        }

        public void Delete(MicroFormat microFormat)
        {
            this.DeleteObject(microFormat);
        }

        public void AttachTo(MicroFormat microFormat)
        {
            this.AttachTo(TABLE_NAME, microFormat, "*");
        }
    }
}